<template>
    <mescroll-uni @init="mescrollInit" :down="downOption" :height="height" @down="refresh" :up="upOption" @up="getData">
        <!-- 数据列表 -->
        <detail-item v-for="(item, index) in datas" :key="index" :sales="1" :item="item"></detail-item>
    </mescroll-uni>
</template>

<script>
import { GetActivityProductPage } from "@/service/api/activity.js"
import { GetSalesPolicyProductPage,GetActivitiesInfoSales } from "@/service/api/salesPolicy.js"
import storage from "@/uni-sub-base/utils/storage.js"
import detailItem from "@/pages_me/components/activity/detail-item.vue"
export default {
    components: {
        detailItem,
    },
    props: {
        height: {
            type: String,
            default: "100px",
        },
        requestData: {
            type: Object,
            default: {},
        },
        activityId: {
            type: String,
            default: "",
        },
    },
    data() {
        return {
            datas: [],
			downOption: {
			    use: true,
			},
        }
    },
    mounted() {
        //#ifndef MP
        this.refresh()
        //#endif
    },
    methods: {
        getData(page) {
            let param = this.requestData
            param.pageSize = page.size
            param.pageIndex = page.num
            param.salesPolicyId = this.activityId
            let webInfo = storage.getCache("webInfo")
            if (webInfo.IsSelectWarehouse == 1) {
                let warehouse = storage.getCache("warehouse")
                param.warehouseId = warehouse.WarehouseId
            }
            GetSalesPolicyProductPage(param).then((res) => {
                this.total = res.Data.RecordAmout
                this.mescroll.endBySize(res.Data.Data.length, res.Data.RecordAmout)
                this.datas = this.datas.concat(res.Data.Data)
            })
        },
        refresh(requestData) {
            this.datas = []
            this.mescroll.resetUpScroll()
        },
    },
}
</script>

<style lang="scss">
.detail-item {
    display: flex;
    margin-top: 30rpx;
    image {
        width: 212rpx;
        height: 212rpx;
        border-radius: 16rpx;
        margin-right: 22rpx;
    }
    .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
    }
    .css-name {
        font-size: $font-size-28;
        font-weight: 700;
        white-space: wrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .css-oprice {
        font-size: $font-size-24;
        color: $app-color-text-tip;
        margin-top: 60rpx;
        // margin-bottom: 10rpx;
    }
    .css-bottom {
        display: flex;
        justify-content: space-between;
        .unit {
            color: #ec612a;
            font-size: 20rpx;
        }
        .css-currentPrice {
            color: #ec612a;
            font-size: 34rpx;
            font-weight: bold;
        }
        .btn {
            border-radius: 32rpx;
            height: 56rpx;
            width: 160rpx;
            font-size: 28rpx;
            margin-right: 0rpx;
            margin-top: -10rpx;
        }
    }
}
</style>
